package kr.hkit.powerjava.chapter10.submit;

import java.util.Random;
import java.util.Scanner;

class Theater {
	private int booking;
	private Random rnd;
	int[] seat2 = new int[10];
	private static int i;
	
	public Theater() {
		rnd = new Random(); 
	}

	Scanner input = new Scanner(System.in);

	public void seat() {

		System.out.print("좌석을 예약하시겠습니까? (1 또는 0)");
		booking = input.nextInt();

		if (booking == 1) {

			System.out.println("현재의 예약 상태는 다음과 같습니다.");
			System.out.println("---------------------------");

			int[] seat1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; 

			for (int nowSeat : seat1) { 
				System.out.print(" " +nowSeat); // 현재 좌석 상태
			}
			System.out.println(" ");
			System.out.println("---------------------------");

		} else {
			System.out.println("좌석 예약이 취소되었습니다.");
		}
	}
	
	public void seat3() {
		for (i = 0; i < seat2.length; i++) {
			seat2[i] = availableSeat();
			System.out.printf("%2d", seat2[i]);
		}
	}

	public int isbooking() {
		System.out.print("\n 몇 번의 좌석을 예약하시겠습니까?");
		int isbook = input.nextInt();

		if (seat2[isbook-1] == 0) {
			System.out.println("예약되었습니다.");
		} else {
			System.out.println("이미 예약된 좌석입니다.");
		}
		return isbook;
	}

	public int availableSeat() {
		return rnd.nextInt(2);
	}
}
